module LogiLang.Pretty (
	prettyPat,
	pprintPat,
	prettyQ,
	pprintQ
	) where

import Text.PrettyPrint

import LogiLang.Environment
import LogiLang.Query

prettyPat :: Pattern -> Doc
prettyPat (Singleton str) = text str
prettyPat (Variable var) = text ("?" ++ var)
prettyPat (Combination children) =
	parens (hsep $ map prettyPat children)
prettyPat _ = error ("Can't pretty print pattern")

pprintPat = render . prettyPat

prettyQ :: Query -> Doc
prettyQ (SimpleQuery pat) = prettyPat pat
prettyQ (CompoundQuery connective subqueries) = 
	text connective $$
		nest 2 (parens (vcat $ map prettyQ subqueries))

pprintQ = render . prettyQ

